import {
  AlbumCreateDto,
  AlbumFindDto,
  AlbumListDto,
  AlbumQueryDto,
  AlbumRemoveDto,
  AlbumUpdateDto,
} from '@/dtos';
import { AlbumService } from '@/services/album.service';
import { ok } from '@/utils';
import { Body, Controller, Delete, Patch, Post, Query } from '@nestjs/common';
import { BaseController } from './base.controller';

@Controller('album')
export class AlbumController extends BaseController {
  constructor(private readonly albumService: AlbumService) {
    super();
  }

  @Post('list')
  async getList(@Body() dto: AlbumListDto) {
    return ok(await this.albumService.list(dto));
  }

  @Post('admin/query')
  async query(@Body() dto: AlbumQueryDto) {
    return ok(await this.albumService.query(dto));
  }

  @Post('admin/find')
  async find(@Body() dto: AlbumFindDto) {
    return ok(await this.albumService.findOne(dto.where, dto.select));
  }

  @Post('admin/create')
  async create(@Body() dto: AlbumCreateDto) {
    return ok(await this.albumService.create(dto.data));
  }

  @Patch('admin/update')
  async update(@Body() dto: AlbumUpdateDto) {
    return ok(await this.albumService.update(dto));
  }

  @Delete('admin/remove')
  async remove(@Query() dto: AlbumRemoveDto) {
    return ok(await this.albumService.remove(dto));
  }
}
